﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Data;
using System.Web.UI.DataVisualization.Charting;



namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class UTallySurveyReportPage : PageBase
    {
        protected override string DWZRef
        {
            get
            {
                return "UTallySurveyReport";
            }
        }
        #region 属性 (查询条件)


        protected string CreateDateFrom
        {
            get
            {
                return GetRequestValue<string>("CreateDateFrom", DateTime.Now.ToString("yyyy-MM-01"));

            }
        }

        protected string CreateDateTo
        {
            get
            {
                return GetRequestValue<string>("CreateDateTo", DateTime.Now.ToString("yyyy-MM-dd"));
            }
        }
        protected string AgentName
        {
            get
            {
                return GetRequestValue<string>("AgentName", "");
            }
        }


        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            DataBind2();
        }


        protected void DataBind2()
        {
            //List<UQuestionTempleteInfo> list = UWarrantyCardController.GetAllUQuestionTempleteByParId(0);

            ////dt.se
            //int allcount = UWarrantyCardController.GetReprotSUMCount(CreateDateFrom, CreateDateTo);

            DataTable dt = UTallySurveyController.GetReport(AgentName, CreateDateFrom, CreateDateTo);
            UQChart1.DataSource = dt;
            UQChart1.Series["Series1"].XValueMember = "item";
            UQChart1.Series["Series1"].YValueMembers = "item2";
            UQChart1.DataBind();
            //UQChart1.Titles["mailtitle"].Text = string.Format(UQChart1.Titles["mailtitle"].Text, list.Find(e => e.UQTID == ParId).Title);
            UQChart1.Titles["TaskTimeTitle"].Text = string.Format(UQChart1.Titles["TaskTimeTitle"].Text, CreateDateFrom, CreateDateTo,string.IsNullOrEmpty(AgentName)?"":",代理商为:"+AgentName);
            UQChart1.Series["Series1"]["DrawingStyle"] = "Cylinder";
            UQChart1.Series["Series1"]["PointWidth"] = "0.4";
            // UQChart1.Series["Series1"].Color=
            Random RandomNum_First = new Random((int)DateTime.Now.Ticks);
            System.Threading.Thread.Sleep(RandomNum_First.Next(50));
            Random RandomNum_Sencond = new Random((int)DateTime.Now.Ticks);
            int int_Red = RandomNum_First.Next(256);
            int int_Green = RandomNum_Sencond.Next(256);
            //  为了在白色背景上显示，尽量生成深色 
            int int_Blue = (int_Red + int_Green > 400) ? 0 : 400 - int_Red - int_Green;
            int_Blue = (int_Blue > 255) ? 255 : int_Blue;

            UQChart1.Series["Series1"].Color = System.Drawing.Color.FromArgb(int_Red, int_Green, int_Blue);


        }
    }
}